package com.qs.springboot.listener;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class AmqpListener {

    @RabbitListener(bindings = {
            @QueueBinding(
                    //消费者绑定的队列
                    value = @Queue(value = "spring.test.queue", durable = "true"),
                    //队列绑定的交换机
                    exchange = @Exchange(value = "spring.test.exchange2", ignoreDeclarationExceptions = "true", type = ExchangeTypes.TOPIC),
                    //队列和交换机绑定的RoutingKey通配
                    key = {"#.#"}
            )
    })
    public void listener(String message) {
        System.out.println("-->>接收到的消息：" + message);
    }
}
